package com.shopping.mall.core.module.goods.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.shopping.mall.core.module.attributeKey.entity.AttributeKey;
import com.shopping.mall.core.module.goodsSpecification.entity.GoodsSpecification;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.util.List;

/**
 * Goods实体类
 *
 * @author zzy
 * @date 2021-08-13
 */
@Data
@TableName("goods")
public class Goods {

    public interface insert {
    }

    public interface update {
    }

    @ApiModelProperty(value = "主键")
    @TableId(type = IdType.UUID)
    @Null(groups = insert.class)
    @NotBlank(groups = update.class, message = "商品id不能为空")
    private String id;

    @ApiModelProperty(value = "一级类型")
    private String primaryTypeId;

    @ApiModelProperty(value = "二级类型")
    private String secondaryTypeId;

    @ApiModelProperty(value = "三级类型")
    private String tertiaryTypeId;

    @ApiModelProperty(value = "商品名")
    private String name;

    @ApiModelProperty(value = "超简介")
    private String lessIntro;

    @ApiModelProperty(value = "简介")
    private String intro;

    @ApiModelProperty(value = "详情")
    private String details;

    @ApiModelProperty(value = "生产商")
    private String producer;

    @ApiModelProperty(value = "主图片")
    @NotNull(message = "mainImage不能为空", groups = {insert.class})
    private String mainImage;

    @ApiModelProperty(value = "轮播图")
    private String subImages;

    @ApiModelProperty(value = "轮播图列表")
    @TableField(exist = false)
    private List<String> subImageList;

    @TableField(exist = false)
    @ApiModelProperty(value = "规格列表")
    private List<AttributeKey> specificationList;

    @TableField(exist = false)
    @ApiModelProperty(value = "规格列表")
    private List<GoodsSpecification> goodsSpecifications;

    @TableField(exist = false)
    private String type;

    @ApiModelProperty(value = "原价(所有规格最低价,用于显示商品列表中价格)")
    @Null(groups = update.class)
    private Double price;

    @ApiModelProperty(value = "现价(所有规格最低价,用于显示折扣价格)")
    @Null(groups = update.class)
    private Double currentPrice;

    @ApiModelProperty(value = "假价格")
    private Double fakePrice;

    @ApiModelProperty(value = "库存数量")
    @Null(groups = update.class)
    private Integer stock;

    @ApiModelProperty(value = "售卖状态(1正常售卖,0停止售卖)")
    @Max(value = 1, groups = update.class)
    @Min(value = 0, groups = update.class)
    private Integer status;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp createAt;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp updateAt;

    @TableField(exist = false)
    private GoodsSpecification specification;

    @TableField(exist = false)
    private boolean isFavorite;

}
